# Contributor: Bart Ribbers <bribbers@disroot.org>
# Maintainer: team/kde <bribbers@disroot.org>

# The group tag is just to easily find this APKBUILD by some scripts for automation
# group=kde-frameworks
pkgname=kimageformats
pkgver=6.1.0
pkgrel=1
pkgdesc="Image format plugins for Qt"
# armhf blocked by extra-cmake-modules
arch="all !armhf"
url="https://community.kde.org/Frameworks"
license="LGPL-2.1-or-later"
makedepends="
	extra-cmake-modules
	karchive-dev
	libavif-dev
	libheif-dev
	libraw-dev
	openexr-dev
	qt6-qtbase-dev
	samurai
	"
checkdepends="xvfb-run"
_repo_url="https://invent.kde.org/frameworks/kimageformats.git"
source="https://download.kde.org/stable/frameworks/${pkgver%.*}/kimageformats-$pkgver.tar.xz"

case "$CARCH" in
s390x)
	;;
*)
	makedepends="$makedepends libjxl-dev"
	;;
esac

build() {
	cmake -B build -G Ninja \
		-DCMAKE_BUILD_TYPE=RelWithDebInfo \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_INSTALL_LIBDIR=lib \
		-DKIMAGEFORMATS_HEIF=ON
	cmake --build build
}

check() {
	case "$CARCH" in
		armv7) xvfb-run ctest --test-dir build --output-on-failure -E "kimageformats-read-(psd|hej2|jxl|xcf)" ;;
		s390x) xvfb-run ctest --test-dir build --output-on-failure -E "kimageformats-(read-(psd|hej2|xcf)|write-avif)" ;;
		*) xvfb-run ctest --test-dir build --output-on-failure -E "kimageformats-read-(psd|hej2|xcf)" ;;
	esac
}

package() {
	DESTDIR="$pkgdir" cmake --install build
}

sha512sums="
99bf723b4a250d5d0c45cc5f77d2149e900f75a65fb70b2b2cd3cf61b60ba62ab7b17251a9a9f9c033681261f7ef4a5a4d5298d15a83d7327395884849ced157  kimageformats-6.1.0.tar.xz
"
